package cn.hfatec.shms.web.xc.xcTjmxb.service;

import java.util.List;
import java.util.HashMap;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.xc.xcTjmxb.model.XcTjmxb;
import cn.hfatec.shms.web.xc.xcTjmxb.dao.XcTjmxbDao;
import cn.hfatec.shms.web.xc.xcTjmxb.model.XcTjmxbParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("XcTjmxbService")
public class XcTjmxbService {

    public static final String BEAN_ID = "XcTjmxbService";

    //注入Dao层
    @Resource(name = "XcTjmxbDao")
    private XcTjmxbDao xcTjmxbDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param xcTjmxbParams
     * @param page
     *
     */
    @Transactional
    public Table queryXcTjmxbTable(XcTjmxbParams xcTjmxbParams, Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("params", xcTjmxbParams);
        return baseDao.queryTableByPage("queryXcTjmxb", params, page);
    }

    /**
     *
     * 插入数据
     * @param xcTjmxb
     *
     */
    @Transactional
    public void saveXcTjmxb(XcTjmxb xcTjmxb) {
        if(xcTjmxb.getId() != null) {
            XcTjmxb result = getXcTjmxb(xcTjmxb.getId());
            if(result != null) {
                xcTjmxbDao.update(xcTjmxb);
            } else {
                xcTjmxbDao.insert(xcTjmxb);
            }
        } else {
            xcTjmxbDao.insert(xcTjmxb);
        }
    }

    /**
     *
     * 删除数据
     * @param id
     *
     */
    @Transactional
    public void deleteXcTjmxb(Integer id) {

        xcTjmxbDao.delete(id);
    }

    /**
     *
     * 删除数据
     * @param xcTjmxbList
     *
     */
    @Transactional
    public void deleteXcTjmxbBatch(List<String> xcTjmxbList) {
        for(String id : xcTjmxbList) {
            deleteXcTjmxb(Integer.valueOf(id));
        }
    }

    /**
     *
     * 根据ID获取数据
     * @param id
     *
     */
    @Transactional
    public XcTjmxb getXcTjmxb(Integer id) {

        return xcTjmxbDao.getXcTjmxbById(id);
    }
}